//package com.github.llyb120.sxmanage;
//
//import org.springframework.context.annotation.Configuration;
//import org.springframework.web.servlet.config.annotation.CorsRegistry;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//
//@Configuration
//public class CorsConfig implements WebMvcConfigurer {
//
//    @Override
//    public void addCorsMappings(CorsRegistry registry) {
//        registry.addMapping("/**")
//                .allowedOrigins("*")
//                .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
//                .allowCredentials(true)
//                .maxAge(3600)
//                .allowedHeaders("*");
//    }
//
////    @Override
////    public void addInterceptors(InterceptorRegistry registry) {
////        registry.addInterceptor(new HandlerInterceptor() {
////            @Override
////            public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
////                if(request.getMethod().equalsIgnoreCase("options") || request.getServletPath().contains("/www/") || request.getServletPath().contains("/static/")){
////                    return true;
////                }
////                boolean flag = Auth.auth(request, response);
////                if(!flag){
////                    response.setStatus(200);
////                    response.setHeader("Content-Type", "application/json; charset=utf-8");
////                    PrintWriter writer = response.getWriter();
////                    writer.write(Json.stringify(Result.error("没有登录")));
////                }
////                return flag;
//////                return auth.auth(request, response);
////            }
////
////        });
////    }
////
////
////    @Override
////    public void addResourceHandlers(ResourceHandlerRegistry registry) {
////        //将所有/static/** 访问都映射到classpath:/static/ 目录下
////        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
////        registry.addResourceHandler("/www/**").addResourceLocations("classpath:/www/");
////    }
//
//
//}
